import { UserDetails } from '@2/typings/oauth2';
import { UserModel } from '@2/typings/model/user.model';
import { RoleModel } from '@2/typings/model/role.model';
import { PermissionModel } from '@2/typings/model/permission.model';

/**
 * @program: microservice-central-portal
 * @description: 登陆用户
 * @author: baiHoo.chen
 * @create: 2022年5月26日
 **/
export class AppUser implements UserModel, UserDetails {
  constructor() {}
  /**
   * 主键标识
   */
  id: number = 0;

  /**
   * 用户姓名
   */
  username: string = '';
  /**
   * 用户 昵称
   */
  nickname: string = '';

  /**
   * 用户 真实姓名
   */
  realName: string = '';
  /**
   * 用户 头像
   */
  avatar: string = '';
  /**
   * 用户 性别
   */
  sex: string = '';
  /**
   * 用户 身份是否有效
   */
  enabled = false;
  /**
   * 数据版本
   */
  version = 0;
  createBy: string = '';
  createTime: string = '';
  deleted: number = 0;
  email: string = '';
  password: string = '';
  phone: string = '';
  tenantId: string = '';
  updateBy: string = '';
  updateTime: string = '';
  homePath = '/dashboard/analysis';
  accountNonExpired = true;
  accountNonLocked = true;
  credentialsNonExpired = true;
  permissions: string[] = [];
  menus: PermissionModel[] = [];
  // 角色
  roles: RoleModel[] = [];

  getUsername(): string | undefined {
    return this.username;
  }

  isAccountNonExpired(): boolean {
    return this.accountNonExpired;
  }

  isAccountNonLocked(): boolean {
    return this.accountNonLocked;
  }

  isCredentialsNonExpired(): boolean {
    return this.credentialsNonExpired;
  }

  isEnabled(): boolean {
    return this.enabled;
  }
}
